/* Operaciones entre vectores */

#include "vector.h"

/* Distancia euclideana en R^n. */
double dist(Vector& v1, Vector& v2, int n)
{
	double norma = 0;
    
    forn(i, n)
        norma += (v1[i] - v2[i]) * (v1[i] - v2[i]);
	
	return sqrt(norma);
}

void swap(Vector& v, int i, int j)
{
	double aux = v[i];
	v[i] = v[j];
	v[j] = aux;
	return;
}

void mostrarVector(const Vector& v, int n)
{
    forn(i, n)
        cout << v[i] << " ";
    cout << endl;
    
    return;
}

void mostrarVectorAlpha(const Vector& v, int n)
{
    cout << "(";
    forn(i, n-1)
    {
		cout << v[i] << ", ";        
    }
    
    cout << v[n-1];
    cout << ")" << endl << endl;
		
	return;
}

inline double random (double valor)
{    
    return (valor*rand())/(RAND_MAX);
}

void generarVector(Vector& v, int n)
{
	forn(i, n)
	{		
		v[i] = random(MAX);
	}	
	
	return;
}
